//
//  WUButtonTabBar.m
//  Home
//
//  Created by 吴军虎吴军虎 on 16/5/6.
//  Copyright © 2016年 LanJue. All rights reserved.
//

#import "WUButtonTabBar.h"

@interface WUButtonTabBar()

@property (nonatomic,retain)UIButton *shoucangButton;
@property (nonatomic,retain)UIImageView *xinImageView;
@property (nonatomic,retain)UIImageView *gongTongImageView;
@property (nonatomic,retain)UIImageView *xinImageView2;
@property (nonatomic,assign)BOOL isSelrct;
@property (nonatomic,retain)UIButton *gongTongButton;
@property (nonatomic, strong) UIView *shouCangView;
@property (nonatomic, strong) UIView *goutongView;
@property (nonatomic, strong) UIButton *centerBtn;

@property (nonatomic,retain)UIView *linV;


@end

@implementation WUButtonTabBar

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = [UIColor whiteColor];
        [self tabBarButton];
        //[self createSubivew];
        
    }
    return self;
}


- (void)tabBarButton{
    
    self.isSelrct = YES;
//    //左边
    self.shouCangView = [[UIView alloc]init];
    
    self.shouCangView.userInteractionEnabled = YES;
    
    self.shouCangView.backgroundColor = [UIColor whiteColor];
    
    [self addSubview:_shouCangView];
    
    [self.shouCangView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(self.mas_bottom).offset(0);
        
        make.left.equalTo(self);
        
        make.size.mas_equalTo(CGSizeMake(self.frame.size.width, 110.00*AUTO_WIDTH/2));
        
    }];
    
    //收藏
    self.shoucangButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.shoucangButton addTarget:self action:@selector(centerAction:) forControlEvents:UIControlEventTouchUpInside];
    [self.shouCangView addSubview:self.shoucangButton];
    [self.shoucangButton mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.centerY.equalTo(self.shouCangView);
        make.height.mas_equalTo(19.00*AUTO_WIDTH*2);
        make.width.mas_equalTo(self.frame.size.width);
        
    }];
    
    
    self.xinImageView = [UIImageView new];
    //实心心
    self.xinImageView.image = [UIImage imageNamed:@"jj"];
    [self.shoucangButton addSubview:self.xinImageView];
    self.xinImageView.contentMode = UIViewContentModeScaleAspectFill;
    [self.xinImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.centerY.equalTo(self.shoucangButton);
        make.centerX.equalTo(self.shoucangButton).offset(-100.00*AUTO_WIDTH/2);
        make.size.mas_equalTo(CGSizeMake(60/2 * AUTO_WIDTH, 60/2*AUTO_HEIGHT));
        
    }];

    
    UILabel *shouangL = [UILabel new];
    [self.shoucangButton addSubview:shouangL];
    [shouangL mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.mas_equalTo(self.xinImageView.mas_right).offset(4 * AUTO_WIDTH);
        make.centerY.mas_equalTo(self.xinImageView);
        make.height.mas_equalTo(self.xinImageView);
    }];
    shouangL.text = @"编辑个人主页";
    shouangL.textColor = GH;
    shouangL.font = [UIFont fontWithName:@"Arial" size:LOGINFONT * AUTO_WIDTH];
    
//
//    self.goutongView = [UIView new];
//    self.goutongView.userInteractionEnabled = YES;
//    self.goutongView.backgroundColor = [UIColor whiteColor];
//    [self addSubview:_goutongView];
//    [self.goutongView mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.bottom.equalTo(self.mas_bottom);
//        
//        make.right.mas_equalTo(@0);
//        
//        make.size.mas_equalTo(CGSizeMake(self.frame.size.width/2, 110.00*AUTO_WIDTH/2));
//        
//    }];
//    self.goutongView.backgroundColor = [UIColor whiteColor];
//    
    
//    //沟通
//    self.gongTongButton = [UIButton new];
//    //裁掉边框
//    self.gongTongButton.layer.masksToBounds = YES;
//    //设置半径
//    self.gongTongButton.layer.cornerRadius = 5;
//    
//    [self.gongTongButton addTarget:self action:@selector(centerAction:) forControlEvents:UIControlEventTouchUpInside];
//    [self.goutongView addSubview:self.gongTongButton];
//    
//    [self.gongTongButton mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.centerY.mas_equalTo(self.goutongView);
//        make.left.mas_equalTo(30/2 * AUTO_WIDTH);
//        make.right.mas_equalTo(-12 * AUTO_WIDTH);
//        make.height.mas_equalTo(19.00*AUTO_WIDTH*2);
//    }];
//
//    
//    self.xinImageView2 = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"edit"]];
//    //  self.xinImageView2.backgroundColor = [UIColor redColor];
//    [self.gongTongButton addSubview:self.xinImageView2];
//    [self.xinImageView2 mas_makeConstraints:^(MASConstraintMaker *make) {
//        
//        make.centerY.equalTo(self.shoucangButton);
//        make.centerX.mas_equalTo(-100.00*AUTO_WIDTH/2);
//        make.size.mas_equalTo(CGSizeMake(27 * AUTO_HEIGHT, 27*AUTO_WIDTH));
//        
//    }];
//    
//    
//    UILabel *gouTongL = [UILabel new];
//    [self.gongTongButton addSubview:gouTongL];
//    [gouTongL mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.left.mas_equalTo(self.xinImageView2.mas_right).offset(4 * AUTO_WIDTH);
//        make.centerY.mas_equalTo(self.xinImageView2);
//        make.height.mas_equalTo(self.xinImageView2);
//    }];
//    gouTongL.text = @"编辑个人主页";
//    gouTongL.textColor = GH;
//    gouTongL.font = [UIFont fontWithName:@"Arial" size:LOGINFONT * TEXTWEIGHT];
//    
//    //阴影
//    UIImageView *shadowImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"purse_shadow"]];
//    [self addSubview:shadowImage];
//    [shadowImage mas_makeConstraints:^(MASConstraintMaker *make) {
//        
//        make.left.right.mas_equalTo(@0);
//        make.bottom.equalTo(self.mas_top);
//        make.height.mas_equalTo(@15);
//    }];
    
}

- (void)changeViewToTypeShopper {
    
    [self.shouCangView mas_updateConstraints:^(MASConstraintMaker *make) {
        
        make.size.mas_equalTo(CGSizeMake(self.frame.size.width/2 - 19 * AUTO_WIDTH, 110.00*AUTO_WIDTH/2));
    }];
    [self.goutongView mas_updateConstraints:^(MASConstraintMaker *make) {
        
        make.size.mas_equalTo(CGSizeMake(self.frame.size.width/2 - 19 * AUTO_WIDTH, 110.00*AUTO_WIDTH/2));
    }];
    
    //[self.centerBtn addTarget:self action:@selector(centerAction:) forControlEvents:UIControlEventTouchUpInside];
}

- (UIButton *)centerBtn {
    
    if (!_centerBtn) {
        
        UIView *view = [[UIView alloc] init];
        view.backgroundColor = [UIColor whiteColor];
        [self addSubview:view];
        view.layer.cornerRadius = 25 * AUTO_WIDTH;
        view.layer.masksToBounds = YES;
        [view mas_makeConstraints:^(MASConstraintMaker *make) {
            
            make.centerX.mas_equalTo(@0);
            make.bottom.mas_offset(@(-15 * AUTO_WIDTH));
            make.size.mas_equalTo(CGSizeMake(25 * 2 * AUTO_WIDTH, 25 * 2 * AUTO_WIDTH));
        }];
        
        _centerBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [_centerBtn setBackgroundImage:[UIImage imageNamed:@"find_center"] forState:UIControlStateNormal];
        [view addSubview:_centerBtn];
        [_centerBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            
            make.center.mas_equalTo(@0);
            make.size.mas_equalTo(CGSizeMake(19 * 2 * AUTO_WIDTH, 19 * 2 * AUTO_WIDTH));
        }];
    }
    
    return _centerBtn;
}

- (void)centerAction:(UIButton *)btn {
    
    if ([btn isEqual:self.shoucangButton]) {
        [self.delegate findButtonClickWith:FINDBUTTONCLICKCOLLECT];
        
        self.isSelrct = !self.isSelrct;
        
        if (self.isSelrct) {
            self.xinImageView.image = [UIImage imageNamed:@"edit"];
            
        } else{
            self.xinImageView.image = [UIImage imageNamed:@"edit"];
            
        }
    } else if ([btn isEqual:self.gongTongButton]) {
        [self.delegate findButtonClickWith:FINDBUTTONCLICKTALK];
        
    } else {
        [self.delegate findButtonClickWith:FINDBUTTONCLICKCENTER];
    }
}

- (void)shouchangButton:(UIButton *)leftBtu{
    NSLog(@"收藏呢");
    
}

- (void)gouTongButton:(UIButton *)rightButton{
    
    [self.delegate YHYgongTongTabBar];
}


@end
